package com.yl.rabbitmq.day07;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.yl.rabbitmq.utils.RabbitMQUtil;

/**
 * @author yangl
 */
public class ReceiveLogsDirect01 {
    public static final String EXCHANGE_NAME = "direct_logs";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMQUtil.getChannel();
        channel.exchangeDeclare(EXCHANGE_NAME, "direct");
        String queueName = channel.queueDeclare("disk", false, false, false, null).getQueue();
        channel.queueBind("disk", EXCHANGE_NAME, "error");
        //接收消息
        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("ReceiveLogs01控制台打印接收到的消息：" + new String(message.getBody(), "UTF-8"));
        };
        //消费者取消息时回调接口
        channel.basicConsume(queueName, true, deliverCallback, consumerTag -> {});

    }
}
